package HomeWork3_3;

import java.util.Scanner;

public class HomeWork3_3_3 {
    public static void main(String[] args) {
        String s;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一串字符:");
        s = sc.nextLine();
        int len = s.length();
        int let = 0, num = 0, spa = 0, oth = 0;
        for (int i = 0; i < len; i++) {
            char ch = s.charAt(i);
            if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
                ++let;
            else if(ch >= '0' && ch <= '9')
                ++num;
            else if(ch == ' ')
                ++spa;
            else
                ++oth;
        }
        System.out.println("字母数为: " + let);
        System.out.println("数字数为: " + num);
        System.out.println("空格数为: " + spa);
        System.out.println("其他字符数为: " + oth);
    }
}
